package com.shop.shard.controller.assembler.user;

import com.shop.shard.controller.command.user.UserCreateCommand;
import com.shop.shard.controller.command.user.UserUpdateCommand;
import com.shop.shard.entity.user.User;

import java.util.Date;

/**
 * @Description: 代码生成器自动生成
 * @author:
 * @Createed Date: 2019-8-16 10:06:57
 * @ModificationHistory: Who  When  What
 * ---------     -------------   --------------------------------------
 **/
public class UserAssembler{
    public static User toUser(UserCreateCommand command){
        User entity = new User();
        /** 身份证号码*/
        entity.setIdNumber(command.getIdNumber());
        /** 姓名*/
        entity.setName(command.getName());
        /** 年龄*/
        entity.setAge(command.getAge());
        /** 性别：1-男；2-女*/
        entity.setGender(command.getGender());
        /** 出生日期*/
        entity.setBirthDate(command.getBirthDate());
        /** 逻辑删除符*/
        Date currentDate = new Date();
        entity.setCreateDate(currentDate);
        entity.setUpdateDate(currentDate);
        return entity;
    }

    public static User toUser(UserUpdateCommand command){
        User entity = new User();
        /** 主键*/
        entity.setUserId(command.getUserId());
        /** 身份证号码*/
        entity.setIdNumber(command.getIdNumber());
        /** 姓名*/
        entity.setName(command.getName());
        /** 年龄*/
        entity.setAge(command.getAge());
        /** 性别：1-男；2-女*/
        entity.setGender(command.getGender());
        /** 出生日期*/
        entity.setBirthDate(command.getBirthDate());
        Date currentDate = new Date();
        entity.setUpdateDate(currentDate);
        return entity;
    }
}